<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<title>log4javascript lite demo</title>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
		<meta name="author" content="Tim Down - tim@log4javascript.org" />
		<meta name="description" content="log4javascript, a logging framework for JavaScript based on log4j" />
		<meta name="robots" content="all" />
		<link rel="stylesheet" type="text/css" media="screen,print" href="../main.css" title="Default" />
		<script type="text/javascript" src="../js/log4javascript_lite.js"></script>
		<script type="text/javascript">
			// <![CDATA[
			var	log = log4javascript.getDefaultLogger();
			log.debug("This is debugging message from the log4javascript lite demo page");

			var words = ["Boothroyd", "who", "took", "over", "two", "years",
					"ago", "and", "continues", "to", "maintain", "that", "the",
					"club", "are", "building", "for", "the", "future", "made",
					"six", "changes", "and", "gave", "a", "first", "Premiership",
					"start", "to", "on-loan", "Brazilian", "midfielder",
					"Douglas", "Rinaldi", "Darius", "Henderson", "and", "Steve",
					"Kabba", "were", "two", "of", "the", "players", "restored",
					"to", "the", "home", "side", "and", "were", "responsible",
					"for", "giving", "Chelsea", "an", "uncomfortable", "start",
					"which", "set", "the", "pattern", "for", "the", "match"
					];

			var loaded = false;

			function generateRandom() {
				var numberOfEntries = parseInt(document.getElementById("numberOfLogEntries").value);
				for (var i = 0; i < numberOfEntries; i++) {
					var numberOfWords = 1 + Math.floor(10 * Math.random());
					var entryWords = [];
					for (var j = 0; j < numberOfWords; j++) {
						entryWords.push(words[Math.floor(Math.random() * words.length)]);
					}
					var entryMessage = entryWords.join(" ");
					var levelNum = Math.floor(Math.random() * 6);
					switch (levelNum) {
						case 0:
							log.trace(entryMessage);
							break;
						case 1:
							log.debug(entryMessage);
							break;
						case 2:
							log.info(entryMessage);
							break;
						case 3:
							log.warn(entryMessage);
							break;
						case 4:
							log.error(entryMessage);
							break;
						case 5:
							log.fatal(entryMessage);
							break;
					}
				}
			}

			function generateObjectExpansion() {
				var debugObj = {
					a: {
						b: "stuff",
						c: 3,
						d: {
							e: ["a", "b", "c"]
						}
					},
					f: "Things",
					g: 5
				};
				log.debug(debugObj);
			}

			function generateError() {
				try {
					throw new Error("Made up error");
				} catch (ex) {
					log.error("Logging an error!", ex);
				}
			}
			// ]]>
		</script>
	</head>
	<body onload="loaded = true; document.getElementById('enabled').checked = true;">
		<div id="container" class="nonav">
			<div id="header">
				<h1><a href="/docs/index.html">log4javascript</a></h1>
			</div>
			<div id="content">
				<div id="nav">
					<a class="navitem" href="http://sourceforge.net/projects/log4javascript" target="_blank" title="Download (opens in new window)">download</a>
					| <a class="navitem" href="../docs/index.html">docs</a>
					| <a class="navitem" href="../docs/quickstart.html">quick start</a>
					| <a class="navitem" href="../docs/manual.html">manual</a>
					| <a class="navitem" href="index.html">demos</a>
					| <a class="navitem" href="http://www.timdown.co.uk/log4javascript" target="_blank">website</a>
				</div>
				<h1>log4javascript lite demo</h1>
				<p>
					<em><strong>NB.</strong> Since the demo below uses pop-up windows, you will
					need to disable any pop-up blockers you may have for it to work.</em>
				</p>
				<p>
					This demo demonstrates the lite edition of log4javascript.
				</p>
				<p>
					Enter a log message below and click on one of the buttons to log
					your message at your desired level.
				</p>
				<div class="example">
					<input type="text" id="logText" value="Put log message here" />
					<input type="button" value="trace" onclick="log.trace(document.getElementById('logText').value)" />
					<input type="button" value="debug" onclick="log.debug(document.getElementById('logText').value)" />
					<input type="button" value="info" onclick="log.info(document.getElementById('logText').value)" />
					<input type="button" value="warn" onclick="log.warn(document.getElementById('logText').value)" />
					<input type="button" value="error" onclick="log.error(document.getElementById('logText').value)" />
					<input type="button" value="fatal" onclick="log.fatal(document.getElementById('logText').value)" />
					<br />
					Generate <input type="text" size="5" id="numberOfLogEntries" value="50" /> random log entries
					<input type="button" value="go" onclick="generateRandom()" />
					<br />
					<input type="button" value="Log exception" onclick="generateError()" />
					<input type="button" value="Log example object" onclick="generateObjectExpansion()" />
					<br />
					<input type="checkbox" id="enabled" onclick="log4javascript.setEnabled(this.checked)" checked="checked" /> <label for="enabled">logging enabled</label>
					<br />
				</div>
			</div>
			<br class="clear" />
			<div id="footer">
				<span class="externallinkinfo">
					<strong>NB.</strong> All external links open in a new window.
				</span>
				Written by Tim Down. <a href="mailto:tim@log4javascript.org">tim@log4javascript.org</a>
				<br />
				log4javascript is distributed under the <a href="http://www.apache.org/licenses/LICENSE-2.0.html"
					title="Apache License, Version 2.0 (opens in new window)" target="_blank">Apache License,
					Version 2.0</a>

			</div>
		</div>
	</body>
</html>
